package com.neusoft.elmboot.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.neusoft.elmboot.exception.exceptions.BaseException;
import com.neusoft.elmboot.po.PlatformRevenue;
import com.neusoft.elmboot.po.dto.BusinessWalletDTO;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 商家钱包服务接口
 */
public interface BusinessWalletService extends IService<PlatformRevenue> {

    /**
     * 获取商家钱包信息
     */
    BusinessWalletDTO getBusinessWalletInfo(String businessId) throws BaseException;

    /**
     * 获取所有商家钱包信息
     */
    List<BusinessWalletDTO> getAllBusinessWalletInfo() throws BaseException;

    /**
     * 处理订单支付（用户付款 → 商家收款 → 平台收费）
     */
    String processOrderPayment(String userId, String businessId, Integer orderId, 
                              BigDecimal amount, String payPwd) throws BaseException;

    /**
     * 处理订单退款（商家退款给用户，仅钱包支付场景）
     */
    String processOrderRefund(String userId, String businessId, Integer orderId,
                             BigDecimal amount) throws BaseException;

    /**
     * 商家钱包提现
     */
    void businessWithdraw(String businessId, String payPwd, BigDecimal amount) throws BaseException;

    /**
     * 获取商家今日收益统计
     */
    Map<String, Object> getTodayRevenueStats(String businessId) throws BaseException;

    /**
     * 获取商家月度收益统计
     */
    Map<String, Object> getMonthlyRevenueStats(String businessId) throws BaseException;

    /**
     * 获取平台总收益统计
     */
    Map<String, Object> getPlatformTotalStats() throws BaseException;

    /**
     * 获取商家钱包交易记录
     */
    List<Map<String, Object>> getBusinessTransactions(String businessId, Integer page, Integer size) throws BaseException;

    /**
     * 初始化商家钱包
     */
    void initBusinessWallet(String businessId) throws BaseException;

    /**
     * 计算平台手续费
     */
    BigDecimal calculatePlatformFee(BigDecimal orderAmount);
}
